package com.gavel.utils;


import java.util.Collection;
public class CollectionUtils {


    public static String join(Collection collection) {
        return join(collection, ",");
    }

    public static String join(Collection collection, String separator) {
        if ( collection==null || collection.size()==0 ) {
            return "";
        }

        StringBuilder builder = new StringBuilder();
        for (Object o : collection) {
            if ( o==null ) {
                continue;
            }
            if ( builder.length() > 0 && separator!=null ) {
                builder.append(separator);
            }
            builder.append(o.toString());
        }

        return builder.toString();
    }

}
